package day8.homeworkII;

import org.junit.Test;

import java.io.File;

public class Task1 {

    static File file = new File("E://");
    public static void main(String[] args) {
        getName(file);
    }

    private static void getName(File file) {
        if (!file.isDirectory()) {
            System.out.println(file.getName());
        } else {
            String[] list = file.list();
            if (list != null) {
                for (int i = 0; i < list.length; i++) {
                    String name = list[i];
                    name = file + "/" + name;
                    File file2 = new File(name);
                    if (file2.isFile()) {
                        System.out.println(file2.getName());
                    } else {
                        //递归调用
                        getName(file2);
                    }
                }
            }
        }
    }
}
